home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / alv.sun / alv.lha / src / rasinfo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-08  |  1.4 KB  |  63 lines

  1. #include <stdio.h>
  2. #include "defs.h"
  3.  
  4. har *progname;
  5. har *filename;
  6. ixrect *pr;
  7.  
  8. #ifdef STANDALONE
  9. ain(argc, argv, envp)
  10. #else
  11. asinfo_main(argc, argv, envp)
  12. #endif
  13.     int argc;
  14.     char **argv;
  15.     char **envp;
  16. {
  17.     int i;
  18.     int print_cmap = FALSE, print_size = TRUE;
  19.     colormap_t colormap;
  20.  
  21.     progname = strsave(argv[0]);
  22.     parse_profile(&argc, argv, envp);
  23.  
  24.     while ((gc = getopt(argc, argv, "nc")) != EOF)
  25.         switch (gc) {
  26.         case 'n':
  27.             print_size = FALSE;
  28.             break;
  29.         case 'c':
  30.             print_cmap = TRUE;
  31.             break;
  32.         case '?':
  33.             errflag++;
  34.             break;
  35.         }
  36.  
  37.     if (errflag)
  38.         error((char *) 0, "Usage: %s: [-c] [infile]\n", progname);
  39.  
  40.     for (stream = 0; optind < argc; stream++, optind++)
  41.         if (stream == 0 && strcmp(argv[optind], "-") != 0)
  42.             if (freopen(argv[optind], mode[stream], f[stream]) == NULL)
  43.                 error("%s %s", PR_IO_ERR_INFILE, argv[optind]);
  44.  
  45.     if ((pr = pr_load(stdin, &colormap)) == NULL)
  46.         error(PR_IO_ERR_RASREAD);
  47.  
  48.     if (print_size) {
  49.         printf("xsize = %d\n", pr->pr_size.x);
  50.         printf("ysize = %d\n", pr->pr_size.y);
  51.         printf("depth = %d\n", pr->pr_depth);
  52.     }
  53.  
  54.     if (print_cmap) {
  55.         printf("Colourmap length = %d\n", colormap.length);
  56.         if (colormap.length == 0)
  57.             printf("No colourmap associated with image - ALV tools assume greyscale\n");
  58.         else
  59.             for (i = 0; i < colormap.length; i++)
  60.                 printf("%d: %d %d %d\n", i, colormap.map[0][i], colormap.map[1][i], colormap.map[2][i]);
  61.     }
  62. }
  63.